(function($){
	$.fn.float = function(args) {	
		args=$.extend({	
						x:  0,
						y:  0,
						floatX: "right",
						floatY: "top",
						duration:500
						}, args); 
		this.each(function(){
			var _this=$(this);
			if(_this.parent()!=$(document.body)){_this.appendTo($(document.body))}
			_this.css("position","absolute")
				.css("zIndex","999");
			_this.bgiframe();
			$(window).scroll(function(){fn()})
			$(window).resize(function(){fn()})
			var fn=function() {
				var dl=$(document).scrollLeft();
				var dt=$(document).scrollTop();
				if(args.floatX=="right")var _left=dl+document.documentElement.clientWidth-args.x-1-_this.outerWidth(true);	
				if(args.floatX=="left")var _left=dl+args.x;	
				if(args.floatY=="bottom")var _top=dt+document.documentElement.clientHeight-args.y-1-_this.outerHeight(true);	
				if(args.floatY=="top")var _top=dt+args.y;	
				_this.animate( { top: _top,left:_left}, { queue: false, duration: args.duration })
			}
			fn();
		})
	}
})(jQuery)
